/* eslint-disable */

import axios, { AxiosRequestConfig } from 'axios';
import qs from 'qs';
import { request } from '../../utils/request';

export interface GetUserGetCurrentUserRes {
  code: string; // 返回编码
  msg: string; // 返回消息
  data: {
    staffid: number; // 员工ID
    staffName: string; // 员工姓名
    email: string;
  };
  traceId: string;
}

/**
 * 获取当前的用户
 */
export async function getUserGetCurrentUser(
  data?: any,
  config?: AxiosRequestConfig,
): Promise<GetUserGetCurrentUserRes> {
  console.log('---- getUserGetCurrentUser');
  return request(data, {
    url: '/user/getCurrentUser',
    method: 'get',
    ...config,
  });
}

export interface GetUserLogoutRes {
  code: string; // 返回编码
  msg: string; // 返回消息
  data: {};
  traceId: string;
}

/**
 * 登出
 */
export async function getUserLogout(
  data?: any,
  config?: AxiosRequestConfig,
): Promise<GetUserLogoutRes> {
  return request(data, {
    url: '/user/logout',
    method: 'get',
    ...config,
  });
}

export interface PostUserLoginRes {
  code: string; // 返回编码
  msg: string; // 返回消息
  data: {};
  traceId: string;
}

/**
 * 登陆
 */
// export async function postUserLogin(
//   data?: any,
//   config?: AxiosRequestConfig,
// ): Promise<PostUserLoginRes> {
//   return request(data, {
//     url: '/user/login',
//     method: 'post',
//     ...config,
//   });
// }
export async function postTeacherLogin(
  data?: any,
  config?: AxiosRequestConfig,
) {
  return request(qs.stringify(data), {
    url: '/teacher/login',
    method: 'post',
    ...config,
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  });
}
export async function poststudentLogin(
  data?: any,
  config?: AxiosRequestConfig,
) {
  return request(qs.stringify(data), {
    url: '/student/login',
    method: 'post',
    ...config,
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  });
}

export interface PostUserRegesiterRes {
  code: string; // 返回编码
  msg: string; // 返回消息
  data: {};
  traceId: string;
}

/**
 * 注册
 */
export async function postUserRegesiter(
  data?: any,
  config?: AxiosRequestConfig,
): Promise<PostUserRegesiterRes> {
  return request(data, {
    url: '/user/regesiter',
    method: 'post',
    ...config,
  });
}

export interface GetUserForgetPwdRes {
  code: string; // 返回编码
  msg: string; // 返回消息
  data: {};
  traceId: string;
}

/**
 * 申请：忘记密码
 */
export async function getUserForgetPwd(
  data?: any,
  config?: AxiosRequestConfig,
) {
  return request(data, {
    url: '/verification',
    method: 'get',
    ...config,
  });
}

export interface PostUserResetPwdRes {
  code: string; // 返回编码
  msg: string; // 返回消息
  data: {};
  traceId: string;
}

/**
 * 重置密码
 */
// export async function postUserResetPwd(
//   data?: any,
//   config?: AxiosRequestConfig,
// ): Promise<PostUserResetPwdRes> {
//   return request(data, {
//     url: '/user/resetPwd',
//     method: 'post',
//     ...config,
//   });
// }
export async function postUserResetPwd(
  data?: any,
  config?: AxiosRequestConfig,
) {
  return request(qs.stringify(data), {
    url: '/password',
    method: 'post',
    ...config,
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  });
}